package com.mobile.manager.utils;

import net.glxn.qrgen.QRCode;
import net.glxn.qrgen.image.ImageType;

import java.io.*;

/**
 * Created by zhangdi on 16/6/22.
 */
public class QRCodeService {

    public void getQRCode(String qrcodeContent,String path,String name){
        ByteArrayOutputStream out = QRCode.from(qrcodeContent).to(ImageType.PNG).stream();
        try
        {

            String outPath =path+"/QRCode/" ;
            String QRname = name+".jpg";
            FileOutputStream fout = new FileOutputStream(new File(outPath+QRname));
            fout.write(out.toByteArray());
            fout.flush();
            fout.close();
        }
        catch (FileNotFoundException e)
        {
            e.printStackTrace();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
    }

}

